package cn.yqx.bankshop.goods.service.impl;

import cn.yqx.bankshop.goods.dao.BuGoodsFormatKeyMapper;
import cn.yqx.bankshop.goods.dao.BuGoodsFormatMapper;
import cn.yqx.bankshop.goods.dao.BuGoodsFormatValMapper;
import cn.yqx.bankshop.goods.pojo.*;
import cn.yqx.bankshop.goods.service.FormatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FormatServiceImpl implements FormatService {
    private static final Integer IS_DEFAULT = 1 ;

    @Autowired
    BuGoodsFormatMapper mapper ;
    @Autowired
    BuGoodsFormatKeyMapper KeyMapper ;
    @Autowired
    BuGoodsFormatValMapper valMapper ;

    @Override
    public List<BuGoodFormatList> getFormateList(Long goodId) {
        return mapper.findFormatList(goodId);
    }

    @Override
    public List<BuGoodsFormat> getGoodFormateByGoodId(Long goodId) {
        BuGoodsFormatExample example = new BuGoodsFormatExample() ;
        example.or().andGoodsIdEqualTo(goodId.intValue());
        List<BuGoodsFormat> list = mapper.selectByExample(example) ;
        return list;
    }

    @Override
    public List<BuGoodsFormatKey> getBuGoodsFormatKeyByGoodId(Long goodId) {
        BuGoodsFormatKeyExample example = new BuGoodsFormatKeyExample() ;
        example.or().andGoodsIdEqualTo(goodId.intValue());
        return KeyMapper.selectByExample(example);
    }

    @Override
    public List<BuGoodsFormatVal> getBuGoodsFormatVal(Long goodId) {
        BuGoodsFormatValExample example = new BuGoodsFormatValExample() ;
        example.or().andGoodsIdEqualTo(goodId.intValue()) ;
        return valMapper.selectByExample(example);
    }
}
